package com.sell.sell.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sell.sell.domain.OrderMaster;
import com.sell.sell.mapper.OrderMasterMapper;
import com.sell.sell.utils.ResultMsgUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/page")
public class OrderManageController {
    /**
     * 分页查询
     */
    @Resource
    private OrderMasterMapper orderMasterMapper;
    @RequestMapping("/findByOpenIdPaging")
    public ResultMsgUtil findByOpenIdPaging(String buyerOpenid, Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        Map param = new HashMap();
        param.put("buyerOpenid",buyerOpenid);
        Page<OrderMaster> data = orderMasterMapper.findByOpenId(param);
        JSONObject result = new JSONObject();
        result.put("data",data);
        result.put("pages",data.getPages());
        result.put("total",data.getTotal());
        return ResultMsgUtil.getMsg(result);
    }
}
